package logging;

/**
 * 现在来创建一个日志级别的枚举，只有两个属性，一个级别名称，一个级别数值（方便做比较）
 * @author Zhongzhicong
 * @date 2023/3/22 16:12
 * @version：1.0
 */
public enum Level {
    ERROR(40000, "ERROR"), WARN(30000, "WARN"), INFO(20000, "INFO"), DEBUG(10000, "DEBUG"), TRACE(5000, "TRACE");

    private int levelInt;
    private String levelStr;

    Level(int i, String s){
        levelInt = i;
        levelStr = s;
    }

    public static Level parse(String levelStr) {
        return valueOf(levelStr.toUpperCase());
    }

    public int toInt() {
        return levelInt;
    }

    public String toString(){
        return levelStr;
    }

    public boolean isGreaterOrEqual(Level level) {
        return levelInt >= level.levelInt;
    }
}
